package com.fzkj.shejimoshi.factory.simple;

/**
 * @DESCRIPTION: TODO 简单工厂/静态工厂
 * @缺点 不易扩展，增加产品需要修改工厂代码
 * @AUTHOR: AnotherOne
 * @DATE: 2021/8/12 13:40
 */
public class SimpleFactory {

    /**
     * 工厂，生产产品
     */
    public static Product getProduct(ProductType type){
        Product product = null;
        switch (type){
            case A:
                return new ProductA();
            case B:
                return new ProductB();
            default:
                return product;
        }
    }

    public static void main(String[] args) {
        Product product = getProduct(ProductType.A);
        System.out.println(product.show());
        System.out.println("=============");
        product = getProduct(ProductType.B);
        System.out.println(product.show());
    }

    /**
     * 产品类别
     */
    enum ProductType{
        A, B
    }

}
